package business.ticket;

import java.sql.Connection;

import parameter.EntryExitType;
import parameter.TicketType;
import parameter.TradeState;
import parameter.TradeType;
import foundation.Ticket;

public class TSSouvenirMultiride extends Ticket {
    
    public TSSouvenirMultiride(){
        ticketType.add(TicketType.SouvenirMultiride);
    }
    
    public void setTradeStateForFlux(EntryExitType eeType) {
        switch (eeType) {
            case Entry:
                tradeState.add(TradeState.ProductMultirideUseOnEntry);
                tradeState.add(TradeState.ProductDelayMultirideUseOnEntry);
                break;
            case Exit:
                tradeState.add(TradeState.ProductMultirideUseOnExit);
                tradeState.add(TradeState.ProductDelayMultirideUseOnExit);
                break;
            case EntryExit:
                tradeState.add(TradeState.ProductMultirideUseOnEntry);
                tradeState.add(TradeState.ProductDelayMultirideUseOnEntry);
                tradeState.add(TradeState.ProductMultirideUseOnExit);
                tradeState.add(TradeState.ProductDelayMultirideUseOnExit);
                break;
            default:
                break;
        }
    }
    
 
    
    @Override
    public long getFlux(Connection conn, EntryExitType eeType, String dateStart,
            String dateEnd) {
        // TODO Auto-generated method stub
        long lNum = 0;
        String sTable;
        String sWhere;
        this.dateStart = dateStart;
        this.dateEnd = dateEnd;
        tradeTpye = TradeType.SingleProduct;
        
        setTradeStateForFlux(eeType);

        sWhere = buildBasicWhereString(false);
        sTable = "in_out_colligate_daily";
        lNum = (long)getSum(conn, "trade_number", sTable, sWhere);
        
        clearTicket();
        
        return lNum;
    }


    @Override
    public double getCompensationFare(Connection conn, String dateStart, String dateEnd) {
        // TODO Auto-generated method stub
        double dNum = 0;
        String sTable;
        String sWhere;
        
        this.dateStart = dateStart;
        this.dateEnd = dateEnd;
        
        tradeTpye = TradeType.SingleProduct;
        tradeState.add(TradeState.ProductMultirideCompensationFare);

        sWhere = buildBasicWhereString(true);
        sTable = "station_detail_daily";
        
        dNum = getSum(conn, "trade_money", sTable, sWhere);
        
        clearTicket();
        return dNum;
    }

    @Override
    public double getSale(Connection conn, String dateStart, String dateEnd) {
        // TODO Auto-generated method stub
        return 0;
    }

    
}
